Gradual Typing for Annotated Type Systems
نویسندگان
چکیده
Refinement type systems have been proposed by a number of researchers to sharpen the guarantees of existing type systems. Examples are systems that distinguish empty and non-empty lists by type, taint tracking and information flow control, dimension analysis, and many others. In each case, the type language is extended with annotations that either abstract semantic properties of values beyond the capabilities of the underlying type language (e.g., empty and non-empty lists) or they express extrinsic properties that are not locally checkable (e.g., taintedness, dimensions). Gradual typing emerged as an approach to combine static and dynamic typing in a single language. Recent work considered a number of variations on gradual typing that are not directly related to dynamic typing, like gradual information flow, gradual typestate, and gradual effect systems. Instead of considering entire types as static or dynamic, these systems focus on gradualizing type refinements. This proliferation of gradual systems begs the question if there is a common underlying structure. In this work, we give a partial answer by outlining a generic approach to “gradualize” existing annotated type systems that support annotations on base types. We illustrate the usefulness of gradual annotation typing with the example of gradual dimension annotations. Type systems with dimensions prevent the programmer to mix up measurements of different dimensions that are represented with a common numeric type. For illustration we consider an ML-like language with simple types where numbers carry a dimension annotation. The following function, calculating an estimated time to arrival, is well-typed in this language. fun eta (dist : float[m]) (vel:float[m/s]) : float[s] = dist / vel The annotated type float[u] represents an integer of dimension u where u ranges over the free abelian group generated by the SI base dimensions: m, s, kg, and so on. Each gain in safety costs flexibility. For example, a straightforward definition of the power function on meters fails to type-check in a system based on simple types. fun pow_m (x : float[m]) (y : int[1]) = if y == 0 then 1[S(1)] else x * pow_m x (y 1) The annotation S(1) indicates a statically checked dimensionless number.
منابع مشابه
Gradual Typing for Functional Languages
Static and dynamic type systems have well-known strengths and weaknesses, and each is better suited for different programming tasks. There have been many efforts to integrate static and dynamic typing and thereby combine the benefits of both typing disciplines in the same language. The flexibility of static typing can be improved by adding a type Dynamic and a typecase form. The safety and perf...
متن کاملPosition Paper: Performance Evaluation for Gradual Typing
Gradually typed programming languages aim to improve software maintenance by allowing programmers to selectively add type annotations to untyped programs. Run-time checks ensure that these typed portions interact soundly with unannotated parts of the program. These checks, however, may introduce unacceptable performance overhead. The extent of the overhead has not been systematically studied an...
متن کاملGradual Pluggable Typing in Java
Gradual typing provides the ability to safely mix untyped or dynamically typed code with statically typed code while maintaining, within the statically typed portion, the guarantees claimed by the static typing. It is motivated by the idea that different amounts of typing are valuable at different times during a software projects development. Less typing is useful at the prototyping stage, wher...
متن کاملGradual Typing for Objects
Static and dynamic type systems have well-known strengths and weaknesses. In previous work we developed a gradual type system for a functional calculus named λ→. Gradual typing provides the benefits of both static and dynamic checking in a single language by allowing the programmer to control whether a portion of the program is type checked at compile-time or run-time by adding or removing type...
متن کاملConsistent Subtyping for All
Consistent subtyping is employed in some gradual type systems to validate type conversions. The original definition by Siek and Taha serves as a guideline for designing gradual type systems with subtyping. Polymorphic types à la System F also induce a subtyping relation that relates polymorphic types to their instantiations. However Siek and Taha’s definition is not adequate for polymorphic sub...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
دوره شماره
صفحات -
تاریخ انتشار 2014